home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgramD2.iso
/
Borland
/
Borland C++ V5.02
/
STDLIB.PAK
/
STACK.CPP
< prev
next >
Wrap
Text File
|
1997-05-06
|
815b
|
47 lines
#include <stack>
#include <vector>
#include <deque>
#include <string>
using namespace std;
int main ()
{
//
// Make a stack using a vector container.
//
stack<int,vector<int> > s;
//
// Push a couple of values on the stack.
//
s.push(1);
s.push(2);
cout << s.top() << endl;
//
// Now pop them off.
//
s.pop();
cout << s.top() << endl;
s.pop();
//
// Make a stack of strings using a deque.
//
stack<string,deque<string> > ss;
//
// Push a bunch of strings on then pop them off.
//
int i;
for (i = 0; i < 10; i++)
{
ss.push(string(i+1,'a'));
cout << ss.top() << endl;
}
for (i = 0; i < 10; i++)
{
cout << ss.top() << endl;
ss.pop();
}
return 0;
}